interface KHTMLElement {
    /**
     * 查找符合条件的元素
     * @param selectors 选择器 @see HTMLElement.prototype.querySelector
     * @param all false: 只查找第一个符合条件的元素;
     * @returns 查找结果元素
     */
    query(selectors: string, all?: false): KHTMLElement;
    /**
     * 查找符合条件的元素
     * @param selectors 选择器 @see HTMLElement.prototype.querySelectorAll
     * @param all true: 查找所有符合条件的元素;
     * @returns 查找结果元素
     */
    query(selectors: string, all: true): KHTMLElement;
}
{
    Object.defineProperty(KHTMLElement.prototype, 'query', {
        writable: false,
        configurable: false,
        enumerable: false,
        value: function (this: KHTMLElement, selectors: string, all: boolean = false) {
            const result = new KHTMLElement();
            if (all === true) {
                this.elements.forEach(ele => { result.push(ele.querySelectorAll(selectors)); });
            } else {
                this.elements.forEach(ele => { result.push(ele.querySelector(selectors)); });
            }
            return result;
        }
    });
}
